package zx.x.modules.app.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import zx.x.modules.app.entity.RoomAppointmentEntity;
import zx.x.modules.app.service.RoomAppointmentService;
import zx.x.common.utils.PageUtils;
import zx.x.common.utils.R;



/**
 * 房间预约表
 *
 * @author x
 * @email x
 * @date 2022-09-29 15:27:48
 */
@RestController
@RequestMapping("app/roomappointment")
public class RoomAppointmentController {
    @Autowired
    private RoomAppointmentService roomAppointmentService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = roomAppointmentService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		RoomAppointmentEntity roomAppointment = roomAppointmentService.getById(id);

        return R.ok().put("roomAppointment", roomAppointment);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody RoomAppointmentEntity roomAppointment){
		roomAppointmentService.save(roomAppointment);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody RoomAppointmentEntity roomAppointment){
		roomAppointmentService.updateById(roomAppointment);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		roomAppointmentService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
